Kameleon-Plus  0.3.2
GeneralFileReader.h
Go to the documentation of this file.
1 /*
2  * FileReader.h
3  *
4  * Created on: Apr 22, 2009
5  * Author: David Berrios
6  */
7 
8 #ifndef GENERALFILEREADER_H_
9 #define GENERALFILEREADER_H_
10 #include <string>
11 #include <vector>
12 #include <iostream>
13 #include "Attribute.h"
14 #include "FileReader.h"
15 #include <boost/unordered_map.hpp>
16 #include "cdf.h"
17 
18 
19 
20 
21 
22 namespace ccmc
23 {
24 
25 
33  {
34 
35  public:
36 
38  long open(const std::string& filename);
39 
40  std::vector<float>* getVariable(const std::string& variable);
41  std::vector<float>* getVariable(long variableID);
42  std::vector<float>* getVariable(const std::string& variable, long startIndex, long count);
43  std::vector<float>* getVariable(long variableID, long startIndex, long count);
44  float getVariableAtIndex(const std::string& variable, long index);
45  float getVariableAtIndex(long variable_id, long index);
46  std::vector<int>* getVariableInt(const std::string& variable);
47  int getVariableIntAtIndex(const std::string& variable, long index);
51  long getNumberOfRecords(const std::string& variable);
52  long getNumberOfRecords(long variable_id);
53  long getVariableID(const std::string& variable);
54  std::string getVariableName(long variable_id);
56  std::string getGlobalAttributeName(long attribute_id);
57  std::string getVariableAttributeName(long attribute_id);
58  Attribute getGlobalAttribute(const std::string& attribute);
59  Attribute getVariableAttribute(const std::string& variable, const std::string& attribute);
60  std::vector<std::string> getVariableAttributeNames();
61  bool doesAttributeExist(const std::string& attribute);
62  bool doesVariableExist(const std::string& variable);
63  long close();
64  //long closeFile();
65  //long openFile(const std::string& filename);
66  const std::string& getCurrentFilename();
68 
69  protected:
70  std::string current_filename;
71 
72  boost::unordered_map<std::string, long> variableIDs;
73  boost::unordered_map<long, std::string> variableNames;
74  boost::unordered_map<std::string, Attribute> gAttributes;
75  boost::unordered_map<long, Attribute> gAttributeByID;
76  boost::unordered_map<std::string, boost::unordered_map<std::string, Attribute> > vAttributes;
79  void initializeVariableIDs();
81 
83 
84  };
85 }
86 
87 #endif /* GENERALFILEREADER_H_ */